package impl

type OptimizeAccountServiceImpl struct {
	*BaseServiceImpl
}

func GetOptimizeAccountServiceImpl() *OptimizeAccountServiceImpl {
	return &OptimizeAccountServiceImpl{GetBaseServiceImpl()}
}

// 将optimize_*开头的表，恢复为这一天的上一天的数据
func (_optimizeAccountServiceImpl *OptimizeAccountServiceImpl) RestoreOptimize(date string) {
	// 恢复optimize_account表中上一轮的数据
	var previousDate *string = _optimizeAccountServiceImpl._stockTransactionDataAllDaoImpl.FindLastDateByDate(date)
	_optimizeAccountServiceImpl._optimizeAccountDaoImpl.TruncateTable()
	_optimizeAccountServiceImpl._optimizeAccountDaoImpl.InsertFromOptimizeAccountLogByDate(*previousDate)

	// 恢复optimize_account_log表中上一轮的数据
	_optimizeAccountServiceImpl._optimizeAccountLogDaoImpl.DeleteByDate(date)

	// 恢复optimize_stock_transact_record表中上一轮的数据
	_optimizeAccountServiceImpl._optimizeStockTransactionRecordDaoImpl.DeleteBySellDateNullAndBuyDate(date)
	_optimizeAccountServiceImpl._optimizeStockTransactionRecordDaoImpl.UpdateNullBySellDate(date)
}
